package stores

import (
	"jvm/nzpJvm/instructions/base"
	"jvm/nzpJvm/runtime_area"
)

// 将操作数栈中一个double存入局部变量表指定索引位置
type DSTORE struct{ base.Index8Instruction }
type DSTORE_0 struct{ base.NoOperandsInstruction }
type DSTORE_1 struct{ base.NoOperandsInstruction }
type DSTORE_2 struct{ base.NoOperandsInstruction }
type DSTORE_3 struct{ base.NoOperandsInstruction }

func (self *DSTORE) Execute(frame *runtime_area.Frame) {
	_dstore(frame, self.Index)
}
func (self *DSTORE_0) Execute(frame *runtime_area.Frame) {
	_dstore(frame, 0)
}
func (self *DSTORE_1) Execute(frame *runtime_area.Frame) {
	_dstore(frame, 1)
}
func (self *DSTORE_2) Execute(frame *runtime_area.Frame) {
	_dstore(frame, 2)
}
func (self *DSTORE_3) Execute(frame *runtime_area.Frame) {
	_dstore(frame, 3)
}
func _dstore(frame *runtime_area.Frame, index uint) {
	// 从栈帧的操作数栈中弹出一个double值，
	double := frame.OperandStack().PopDouble()
	frame.LocalVars().SetDouble(index,double)
}
